<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%--
Important usage note:
Requirements:
  1. Add the following property in the bean used in the including jsp:
     <form-property name="attContainer" type="com.broadvision.portal.foundation.action.microsite.attachment.AttachmentsContainer" />
 
  2. In the action class used to retrieve an exisiting content and forward to the view jsp page, add
     some codes similar to the following:
     PropertyUtils.setSimpleProperty(view-bean-name,
                           AttachmentActionLogic.ATTACHMENTS_CONTAINER_NAME, 
                           AttachmentsContainer.getInstance(object_Attached_To);
                           
     For example, if the page is to show the details of a meeting, 
     then the meeting object should replace "object_Attached_To".
                           
  3. In the including jsp, give the bean which contains the 
     AttachmentsContainer instance a new reference name: formBeanUsed, 
     and put it into request scope.
     <bean-av:define id="beanUsed" name="bean_name" toScope="request" />
  
--%>

<%-- add -av to all taglib prefix to avoid conflict with parent / container JSP --%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html-av" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean-av" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic-av" %>

<%@ page import="com.broadvision.portal.foundation.action.microsite.attachment.AttachmentsContainer" %>

<bean-av:define id="attContainerForView" name="beanUsed" property="attContainer" toScope="page"/>

<Script language="JavaScript">
function downloadAttachment(linkObj, attachmentId) 
{
  var url ='<html-av:rewrite page="/cs/attachmentDownload.do" name="micrositeNaviInfoView" property="urlParams" />';
  url += "&attId=" + attachmentId;
 
  linkObj.href = url;
  return true; 
}

</Script>

<%
  // In JBoss, there is a local variable called attContainerForView
  // from <bean-av:define> above.
  // But, this is missing in Weblogic. Therefore, we need to get the
  // value from the page scope and assign it to a different variable.
  AttachmentsContainer attContainerForView2 =  (AttachmentsContainer)pageContext.getAttribute("attContainerForView");
  Object attachmentsForView = attContainerForView2.getAttachments();
  pageContext.setAttribute("attachmentsForView", attachmentsForView);
%>

<bean-av:size id="attachmentsCountForView" name="attachmentsForView" />

<logic-av:greaterThan name="attachmentsCountForView" value="0">
  <div class="pageSubsubtitle">
    <span class="left"><bean-av:message key="cs.attachment.attachments.list" /></span>
    <span class="right">&nbsp;</span>
  </div> 
  <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Attachments list" width="100%">
    <tr class="listHeader"> 
      <th id="Filename" align="left"><bean-av:message key="cs.name" /></th>
    </tr>
    <logic-av:iterate id="attachment" name="attachmentsForView" 
         type="com.broadvision.portal.foundation.action.microsite.attachment.AttachmentDTO"
         indexId="index">
      <TR class='<%=index.intValue() % 2 == 0 ? "listEven" : "listOdd"%>'>
        <TD headers="Filename" align="left">
          <html-av:img page="/cs/images/icons/cicon_attachgeneric.gif" border="0" width="22" height="18" border="0" altKey="cs.attachment" titleKey="cs.attachment" align="absmiddle" />
          <a href="#" onclick="return downloadAttachment(this, <bean-av:write name="attachment" property="id" />)"><bean-av:write name="attachment" property="name" /></a>
          <bean-av:write name="attachment" property="formattedFileSize" />
        </TD>
      </TR>
    </logic-av:iterate>
  </table>
</logic-av:greaterThan>
